Field of the Invention
The present invention relates to the function of an operating system and, more particularly, to an interrupt process.
Description of the Related Art
Operating systems for dedicated devices such as cell phones, as well as operating systems for general-purpose devices such as personal computers, are required to perform advanced functions on a growing scale. Particularly, an operating system capable of executing a plurality of tasks by a single central processing unit (CPU) (hereinafter, an OS of this type will be referred to as a multi-task OS) is now built in a large number of electronic devices.
A multi-task OS divides the processing time of a CPU into units of time (time slices) and assigns time slices to a plurality of tasks. Each task is allowed to use the CPU only while being assigned a time slice from the OS. A single task can be executed in a given time slice. Since a time slice is a very short period of time, it looks to a user as if the plurality of tasks is being executed at the same time. According to such a method of processing, the processing power of the CPU is effectively used by giving the right for execution to task B when task A reaches a state to wait for an input and thus no longer needs the computing power of the CPU. The term “right for execution” is synonymous with the right to use the CPU.
Transfer of the right for execution by the multi-task OS will be referred to as a task switch. A task switch occurs when a time slice expires or when a task executes a predetermined instruction. A multi-task OS saves context information of a task being executed in a task control block (TCB) when a task switch is to be executed. Context information is data related to data stored in a register of the CPU while the task is being executed or data related to the state of execution. A TCB is an area reserved in a memory to store information unique to a task. A multi-task OS saves context information of a task being executed in a TCB, then selects a task to give the right for execution to, reads context information from the TCB for the selected task, and loads the information into a CPU register. In this way, each task continues its process step by step in units of time slices.
While a multi-task OS has the advantage of being capable of executing a plurality of tasks efficiently, it also involves a disadvantage of incurring the overhead associated with saving and loading context information. Normally, the advantage of a multi-task OS far surpasses the overhead associated with a task switch.
Recently, real-time operating systems with severe requirements for completion of a process within a predefined period of time are being used extensively especially in embedded systems. In an RTOS with severe time requirements, overhead incurred in a task switch may affect the performance of the system as a whole significantly.
An RTOS should instantly respond to various external factors that occur on an irregular base such as completion of DMA transfer, reception of a communication packet, or depression of a key of the keyboard. Normally, when an interrupt request signal indicating the occurrence of an external factor is received, the RTOS executes an “interrupt process” by activating a special task. For improvement of the performance of the RTOS, reduction of the overhead at the time of responding to an external factor is particularly important.